Building LW Containers (cont.)
public void paint(Graphics g) {
        Dimension size = getSize();
        if (background != null) {
          Dimension isize = 
	     new Dimension(background.getWidth(this),
          		          background.getHeight(this));
          for (int y=0; y<size.height; y+=isize.height) {
            for (int x=0; x<size.width; x+=isize.width) {
                 g.drawImage(background, x, y,
                             isize.width, isize.height, this);
            }
          }
        }
        // You MUST call super.paint(g) so lightweight
        // containees will get painted.
        super.paint(g);
    }
}

Return to Tracks